<?php


namespace app\common\service\auth;


use think\Facade;
use think\facade\Log;

class AuthBase
{
    public function from()
    {
        $appname = app('http')->getName();

        $from = input('from', '');

        if ($appname == 'app') {
            switch ($from) {
                case FROM_APP_ADMIN:
                    $appname = FROM_APP_ADMIN;
                    break;
                case FROM_APP_AGENT:
                    $appname = FROM_APP_AGENT;
                    break;
                case FROM_APP_API:
                    $appname = FROM_APP_API;
                    break;
                case FROM_OPEN_PLATFORM_API:
                    $appname = FROM_OPEN_PLATFORM_API;
                    break;
            }
        }

        return $appname;
    }


    /**
     * 平台属性
     * @return string
     */
    public function platform()
    {
        if ($this->from() == 'ymsh') {
            if (!$this->isMerchant()) {
                return PLATFORM_ADMIN;
            }
            return PLATFORM_AGENT;
        }

        return $this->from();

    }

    public function agentId()
    {
        Log::info('没有获取到代理id');
        return 0;
    }

    public function channelId(){
        return 0;
    }
}